package org.gwt.grin.rebind.features;

import org.gwt.grin.client.features.Image;
import org.gwt.grin.client.util.BgImage;
import org.gwt.grin.client.util.Color;
import org.gwt.grin.rebind.ShowBuilder;

import com.google.gwt.uibinder.rebind.IndentedWriter;

public class SEImage extends SEBox {

	private final String url;

	public SEImage(String name, int x, int y, int width, int height,
			String url, int outlineWidth, Color outlineColor, Color fillColor,
			BgImage bgImage) {
		super(name, x, y, width, height, outlineWidth, outlineColor, fillColor,
				bgImage);
		this.url = url;
	}

	@Override
	protected String getClassName() {
		return Image.class.getName();
	}

	@Override
	public void setup(IndentedWriter w, ShowBuilder builder) {
		String vn = getVN(builder);
		w.write("%s.setup(%d, %d, %d, %d, %d, %s, %s, %s, %s);", vn, x, y,
				width, height, outlineWidth, makeColor(outlineColor),
				makeColor(fillColor), makeBgImage(bgImage),
				makeScalingModel(builder));
		w.write("%s.setUrl(\"%s\");", vn, url);
	}
}
